package com.oocl.o2o.admin.listener;

import java.util.Date;

import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.omg.CORBA.OMGVMCID;

import com.oocl.o2o.admin.entity.ComplaintInfo;
import com.oocl.o2o.admin.entity.Merchant;
import com.oocl.o2o.admin.service.AdvertisementService;
import com.oocl.o2o.admin.service.ComplaintInfoService;
import com.oocl.o2o.admin.service.MerchantService;
import com.oocl.o2o.connectutil.assist.JsonUtil;
import com.oocl.o2o.connectutil.dto.ComplaintDTO;

public class ComplaintInfoJMSListener implements MessageListener{
	
	@Resource(name="complaintInfoServiceImpl")
	private ComplaintInfoService complaintInfoService;
	
	@Resource(name="merchantServiceImpl")
	private MerchantService merchantService;

	@Override
	public void onMessage(Message message) {

		TextMessage textMsg = (TextMessage) message;  
        try {  
        	//log:收到注册内容
            System.out.println("接收新的投诉消息内容------" );
            ComplaintDTO complaintDTO = JsonUtil.getObjectFromJson(textMsg.getText(), ComplaintDTO.class);
            
            //业务方法
            complaintInfoService.saveComplaintInfo(complaintDTO);
                 
            message.acknowledge();
        } catch (JMSException e) {  
            e.printStackTrace();  
        }  
	}

}
